import request from '@/utils/request';

export async function getById(projectId, docId) {
    return request(`/project/${projectId}/doc/article/${docId}`, {
        method: 'GET'
    });
}


export async function deleteDir(projectId, dirId) {
    return request(`/project/${projectId}/doc/article/dir/${dirId}`, {
        method: 'DELETE'
    });
}

export async function list(projectId, params) {
    return request(`/project/${projectId}/doc/article/list`, {
        method: 'GET',
        params: params
    });
}



export async function latestView(projectId) {
    return request(`/project/${projectId}/doc/article/latestView`, {
        method: 'GET',
    });
}


export async function saveArticle(projectId, data) {
    return request(`/project/${projectId}/doc/article`, {
        method: 'POST',
        data: data
    });
}

export async function updateArticle(projectId, docId, data) {
    return request(`/project/${projectId}/doc/article/${docId}`, {
        method: 'POST',
        data: data
    });
}

export async function updateArticleDir(projectId, docId, data) {
    return request(`/project/${projectId}/doc/article/${docId}/updateDir`, {
        method: 'POST',
        data: data
    });
}

export async function updateArticleAcl(projectId, docId, data) {
    return request(`/project/${projectId}/doc/article/${docId}/updateAcl`, {
        method: 'POST',
        data: data
    });
}

export async function releaseArticle(projectId, docId) {
    return request(`/project/${projectId}/doc/article/${docId}/release`, {
        method: 'POST',
    });
}


export async function deleteArticle(projectId, docId) {
    return request(`/project/${projectId}/doc/article/${docId}`, {
        method: 'DELETE',
    });
}